package com.snowflake.ecatalog.repository;

import java.util.Collection;
import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.snowflake.ecatalog.entity.ResourceInfo;

/**
 * 资源路径
 */
public interface ResourceInfoDao extends PagingAndSortingRepository<ResourceInfo, Long>,
		JpaSpecificationExecutor<ResourceInfo> {

	// Page<ResourceInfo> findByUserId(Long id, Pageable pageRequest);

	List<ResourceInfo> findByOwnerIdAndOwnerType(Long ownerId, int ownerType);

	@Modifying
	@Query("delete from ResourceInfo resourceInfo where resourceInfo.ownerId=?1 and ownerType=?2")
	void deleteByOwner(Long id, int type);

	List<ResourceInfo> findByOwnerIdInAndOwnerType(Collection<Long> ownerIds, int ownerType);
}
